using NUnit.Framework;

namespace DatabaseUnitTesting.Utilities.DataCompare.Tests
{
    [TestFixture]
    public class DiffClassesTests
    {
        private Column idOne;
        private Column idTwo;
        private Column priceOne;
        private Column priceTwo;
        private Row rowOne;
        private Row rowTwo;
        private Row rowThree;
        private Row rowFour;
        private Table tableOne;
        private Table tableTwo;
        private Table tableThree;
        private Database one;
        private Database two;
        private Database three;

        [TestFixtureSetUp]
        public void Setup()
        {
            idOne = new Column("id", "1");
            idTwo = new Column("id", "2");
            priceOne = new Column("price", "94.67");
            priceTwo = new Column("price", "94.65");

            rowOne = new Row("in1");
            rowOne.AddColumn(idOne);
            rowOne.AddColumn(priceOne);

            rowTwo = new Row("in1");
            rowTwo.AddColumn(idTwo);
            rowTwo.AddColumn(priceOne);

            rowThree = new Row("in1");
            rowThree.AddColumn(idOne);
            rowThree.AddColumn(priceTwo);

            rowFour = new Row("in1");
            rowFour.AddColumn(idTwo);
            rowFour.AddColumn(priceTwo);

            tableOne = new Table("dbo.testTable1","dbo.testTable1");
            tableOne.AddRow(rowOne);

            tableTwo = new Table("dbo.testTable1", "dbo.testTable1");
            tableTwo.AddRow(rowTwo);

            tableThree = new Table("dbo.testTable3", "dbo.testTable3");
            tableThree.AddRow(rowOne);
            tableThree.AddRow(rowTwo);

            one = new Database();
            one.AddTable(tableOne);

            two = new Database();
            two.AddTable(tableTwo);

            three = new Database();
            three.AddTable(tableOne);
            three.AddTable(tableThree);
        }

        [Test]
        public void VerifyTablesTest()
        {
            Assert.IsTrue(tableOne.Equals(tableOne));
            Assert.IsFalse(tableTwo.Equals(tableOne));
            Assert.IsFalse(tableOne.Equals(tableThree));
        }

        [Test]
        public void VerifySchemasTest()
        {
            Assert.IsTrue(one.Equals(one));
            Assert.IsFalse(one.Equals(two));
            Assert.IsFalse(one.Equals(three));
        }
    }
}